using IM.Easy.Core.ServiceLifetime;
using IM.Easy.Core.Services;
using IM.Easy.Core.Utils;
using IM.Easy.Infrastructure.Query;
using IM.Easy.Entity.System;
using IM.Easy.SystemServices.Dtos;

namespace IM.Easy.SystemServices.IServices
{
    public interface IExternalUserAccountService : IAppServices<ExternalUserAccount>
    {
        /// <summary>
        /// 创建一个新实体
        /// </summary>
        /// <param name="entity">要创建的实体</param>
        /// <returns>创建后的实体</returns>
        ExternalUserAccount Create(ExternalUserAccount entity);

        /// <summary>
        /// 根据 ID 获取实体
        /// </summary>
        /// <param name="id">实体的唯一标识</param>
        /// <returns>获取的实体</returns>
        ExternalUserAccount GetById(long id);


        /// <summary>
        /// 获取所有实体
        /// </summary>
        /// <returns>所有实体的列表</returns>
        PageResponse<ExternalUserAccount> GetPageList(ExternalUserAccountQueryDto query);

        /// <summary>
        /// 更新一个已有的实体
        /// </summary>
        /// <param name="entity">更新后的实体</param>
        /// <returns>更新后的实体</returns>
        bool Update(ExternalUserAccount entity);

        /// <summary>
        /// 根据 ID 删除实体
        /// </summary>
        /// <param name="id">要删除的实体的唯一标识</param>
        /// <returns>操作是否成功</returns>
        bool Delete(params long[] key);

        /// <summary>
        /// 获取本地账户
        /// </summary>
        /// <param name="provider"></param>
        /// <param name="openId"></param>
        /// <returns></returns>
        SysUser GetLocalAccount(string provider, string openId);

        /// <summary>
        /// 绑定当前账户
        /// </summary>
        /// <param name="user"></param>

        ExternalUserAccount BindLocalAccount(SysUser user, ExternalUserAccount externalUser);

        /// <summary>
        /// 解除绑定
        /// </summary>
        /// <param name="bindId"></param>
        void Unbind(long bindId);

        /// <summary>
        /// 绑定校验
        /// </summary>
        /// <param name="externalUser"></param>
        /// <returns></returns>
        bool BindValid(ExternalUserAccount externalUser);

        /// <summary>
        /// 通过提供商和开放ID获取用户信息
        /// </summary>
        /// <param name="provider"></param>
        /// <param name="openId"></param>
        /// <returns></returns>
        ExternalUserAccount Get(string provider, string openId);
    }
}
